/*
 * @Author: your name
 * @Date: 2021-09-01 18:40:40
 * @LastEditTime: 2021-09-27 00:11:09
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \egg-example\app\controller\caty.js
 */
/*
 * @Author: your name
 * @Date: 2021-08-31 14:37:34
 * @LastEditTime: 2021-09-01 18:39:14
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \egg-example\app\controller\home.js
 */
'use strict';
const Controller = require('egg').Controller;

class HomeController extends Controller {
    async index() {
        const { ctx } = this;
        ctx.body = '接口可以用啦';
    }

    //===========城市数据=============
    async path() {
        const { ctx } = this;
        const { username } = ctx.query;
        // 判断数据库里面是否存在该用户
        const user = await this.app.mysql.get('login', { username });
        console.log(user.nickname);
        if (user.nickname === "管理员") {
            ctx.body = [
                {
                    name: user.nickname,
                },
                [{
                    path: "/home",
                    children: [
                        {
                            path: "/home/welcome",
                        },
                        {
                            path: "/home/workbench",
                            title: '工作台'
                        },
                        {
                            path: "/home/goods",
                            title: "商品",
                            children: [
                                {
                                    path: "/home/goods/goods_management",
                                    title: "商品管理"
                                },
                                {
                                    path: "/home/goods/goods_classfily",
                                    title: "商品分类"
                                },
                                {
                                    path: "/home/goods/goods_size",
                                    title: "商品规格"
                                },
                                {
                                    path: "/home/goods/goods_evaluation",
                                    title: "商品评价"
                                },
                                {
                                    to: "/home/goods/goods_management",
                                    from: "/home/goods"
                                }
                            ]
                        },
                        {
                            path: "/home/marketing",
                            title: '营销',
                            children: [
                                {
                                    path: "/home/marketing/seckill",
                                    title: "秒杀管理",
                                    children: [
                                        {
                                            path: "/home/marketing/seckill/secConfig",
                                            title: "秒杀配置"
                                        },
                                        {
                                            path: "/home/marketing/seckill/kill_goods",
                                            title: "秒杀商品"
                                        },
                                        {
                                            to: "/home/marketing/seckill/secConfig",
                                            from: "/home/marketing/seckill"
                                        }
                                    ]
                                },
                                {
                                    path: "/home/marketing/bargain",
                                    title: "砍价管理",
                                    children: [
                                        {
                                            path: "/home/marketing/bargain/bargain_goods",
                                            title: "砍价商品"
                                        },
                                        {
                                            path: "/home/marketing/bargain/bargain_list",
                                            title: "砍价列表"
                                        },
                                        {
                                            to: "/home/marketing/bargain/bargain_goods",
                                            from: "/home/marketing/bargain"
                                        }
                                    ]
                                },
                                {
                                    path: "/home/marketing/themanagement",
                                    title: "直播管理",
                                    children: [
                                        {
                                            path: "/home/marketing/themanagement/live_streaming",
                                            title: "直播列表"
                                        },
                                        {
                                            path: "/home/marketing/themanagement/create_live",
                                            title: "创建直播"
                                        },
                                        {
                                            to: "/home/marketing/themanagement/live_streaming",
                                            from: "/home/marketing/themanagement"
                                        }
                                    ]
                                },
                                {
                                    path: "/home/marketing/group_booking",
                                    title: "拼团管理",
                                    children: [
                                        {
                                            path: "/home/marketing/group_booking/booking_shop",
                                            title: "拼团商品"
                                        },
                                        {
                                            path: "/home/marketing/group_booking/booking_list",
                                            title: "拼团列表"
                                        },
                                        {
                                            to: "/home/marketing/group_booking/booking_shop",
                                            from: "/home/marketing/group_booking"
                                        }
                                    ]
                                },
                                {
                                    to: "/home/marketing/seckill",
                                    from: "/home/marketing"
                                }
                            ]
                        },
                        {
                            path: "/home/order",
                            title: "订单",
                            children: [
                                {
                                    path: "/home/order/orderadmin",
                                    title: "订单管理"
                                },
                                {
                                    path: "/home/order/order_summarace",
                                    title: "订单概述"
                                },
                                {
                                    path: "/home/order/evaluate",
                                    title: "评价管理"
                                },
                                {
                                    path: "/home/order/distribution",
                                    title: "订单配送"
                                },
                                {
                                    to: "/home/order/orderadmin",
                                    from: "/home/order"
                                }
                            ]
                        },
                        {
                            path: "/home/commander",
                            title: "团长",
                            children: [
                                {
                                    path: "/home/commander/ckeckAmdin",
                                    title: "团长管理"
                                },
                                {
                                    path: "/home/commander/grade",
                                    title: "团长审核"
                                },
                                {
                                    path: "/home/commander/checkList",
                                    title: "团长等级"
                                },
                                {
                                    path: "/home/commander/setting",

                                    title: "设置"
                                },
                                {
                                    path: "/home/commander/way",
                                    // component: Way,
                                    title: "路线"
                                },
                                {
                                    path: "/home/commander/money",
                                    // component: Headlist,
                                    title: "佣金流水"
                                },
                                {
                                    to: "/home/commander/ckeckAmdin",
                                    from: "/home/commander"
                                }
                            ]
                        },
                        // {
                        //     path: "/home/store",
                        //     // component: Store,
                        //     title: "门店",
                        //     children: [
                        //         {
                        //             path: "/home/store/proposer",
                        //             // component: Proposer,
                        //             title: "申请列表"
                        //         },
                        //         {
                        //             path: "/home/store/deploy",
                        //             // component: Deploy,
                        //             title: "配置"
                        //         },
                        //         {
                        //             path: "/home/store/outlet",
                        //             // component: Outlet,
                        //             title: "门店"
                        //         },
                        //         {
                        //             path: "/home/store/product",
                        //             // component: Product,
                        //             title: "商品"
                        //         },
                        //         {
                        //             path: "/home/store/indent",
                        //             // component: Indent,
                        //             title: "订单"
                        //         },
                        //         {
                        //             path: "/home/store/deposit",
                        //             // component: Deposit,
                        //             title: "提现"
                        //         },
                        //         {
                        //             path: "/home/store/maturity",
                        //             // component: Maturity,
                        //             title: "到店付款"
                        //         },
                        //         {
                        //             to: "/home/store/proposer",
                        //             from: "/home/store"
                        //         }
                        //     ]
                        // },
                        // {
                        //     path: "/home/warehouse",
                        //     // component: Warehouse,
                        //     title: "仓库",
                        //     children: [
                        //         {
                        //             path: "/home/warehouse/keeper",
                        //             // component: Keeper,
                        //             title: "仓库管理"
                        //         },
                        //         {
                        //             path: "/home/warehouse/delivery",
                        //             // component: Delivery,
                        //             title: "配送小区"
                        //         },
                        //         {
                        //             path: "/home/warehouse/stock",
                        //             // component: Stock,
                        //             title: "入库管理"
                        //         },
                        //         {
                        //             path: "/home/warehouse/inquire",
                        //             // component: Inquire,
                        //             title: "入库查询"
                        //         },
                        //         {
                        //             path: "/home/warehouse/breakdown",
                        //             // component: BreakDown,
                        //             title: "出库管理"
                        //         },
                        //         {
                        //             path: "/home/warehouse/breaksearch",
                        //             // component: BreakSearch,
                        //             title: "出库查询"
                        //         },
                        //         {
                        //             path: "/home/warehouse/takestock",
                        //             // component: TakeStock,
                        //             title: "盘点管理"
                        //         },
                        //         {
                        //             path: "/home/warehouse/repertory",
                        //             // component: Repertory,
                        //             title: "现有库存"
                        //         },
                        //         {
                        //             to: "/home/warehouse/keeper",
                        //             from: "/home/warehouse"
                        //         }
                        //     ]
                        // },
                        // {
                        //     path: "/home/retailstore",
                        //     // component: RetailStore,
                        //     title: "分销",
                        //     children: [
                        //         {
                        //             path: "/home/retailstore/member",
                        //             // component: Member,
                        //             title: "超级会员"
                        //         },
                        //         {
                        //             path: "/home/retailstore/agent",
                        //             // component: Agent,
                        //             title: "代理商",
                        //         },
                        //         {
                        //             path: "/home/retailstore/operator",
                        //             // component: OperAtor,
                        //             title: "运营商",
                        //         },
                        //         {
                        //             path: "/home/retailstore/brokerage",
                        //             // component: BrokeRage,
                        //             title: "佣金记录",
                        //         },
                        //         {
                        //             path: "/home/retailstore/aduit",
                        //             // component: Aduit,
                        //             title: "会员审核",
                        //         },
                        //         {
                        //             path: "/home/retailstore/settingup",
                        //             // component: SettingUp,
                        //             title: "设置 ",
                        //         },
                        //         {
                        //             to: "/home/retailstore/member",
                        //             from: "/home/retailstore"
                        //         }
                        //     ]
                        // },
                        // {
                        //     path: "/home/applet",
                        //     // component: Applet,
                        //     title: "小程序",
                        //     children: [
                        //         {
                        //             path: "/home/applet/pay",
                        //             // component: Pay,
                        //             title: "支付",
                        //         },
                        //         {
                        //             to: "/home/applet/pay",
                        //             from: "/home/applet"
                        //         }
                        //     ]
                        // },
                        {
                            path: "/home/authority",
                            // component: Authority,
                            title: "权限",
                            children: [
                                {
                                    path: "/home/authority/staff",
                                    // component: Staff,
                                    title: "员工管理",
                                },
                                // {
                                //     path: "/home/authority/role",
                                //     // component: Role,
                                //     title: "角色管理",
                                // },
                                // // {
                                //     path: "/home/authority/service",
                                //     // component: Service,
                                //     title: "客服管理",
                                // },
                                {
                                    to: "/home/authority/staff",
                                    from: "/home/authority"
                                }
                            ]
                        },
                        {
                            to: "/home/welcome",
                            from: "/home"
                        }
                    ]
                }]
            ]
        } else {
            ctx.body = [
                {
                    name: user.nickname,
                },
                [{
                    path: "/home",
                    children: [
                        {
                            path: "/home/welcome",
                        },
                        {
                            path: "/home/workbench",
                            title: '工作台'
                        },
                        {
                            path: "/home/goods",
                            title: "商品",
                            children: [
                                {
                                    path: "/home/goods/goods_management",
                                    title: "商品管理"
                                },
                                {
                                    path: "/home/goods/goods_classfily",
                                    title: "商品分类"
                                },
                                {
                                    path: "/home/goods/goods_size",
                                    title: "商品规格"
                                },
                                {
                                    path: "/home/goods/goods_evaluation",
                                    title: "商品评价"
                                },
                                {
                                    to: "/home/goods/goods_management",
                                    from: "/home/goods"
                                }
                            ]
                        },
                        {
                            path: "/home/marketing",

                            title: '营销',
                            children: [
                                {
                                    path: "/home/marketing/seckill",
                                    title: "秒杀管理",
                                    children: [
                                        {
                                            path: "/home/marketing/seckill/secConfig",
                                            title: "秒杀配置"
                                        },
                                        {
                                            path: "/home/marketing/seckill/kill_goods",
                                            title: "秒杀商品"
                                        },
                                        {
                                            to: "/home/marketing/seckill/secConfig",
                                            from: "/home/marketing/seckill"
                                        }
                                    ]
                                },
                                {
                                    path: "/home/marketing/bargain",

                                    title: "砍价管理",
                                    children: [
                                        {
                                            path: "/home/marketing/bargain/bargain_goods",
                                            title: "砍价商品"
                                        },
                                        {
                                            path: "/home/marketing/bargain/bargain_list",
                                            title: "砍价列表"
                                        },
                                        {
                                            to: "/home/marketing/bargain/bargain_goods",
                                            from: "/home/marketing/bargain"
                                        }
                                    ]
                                },
                                {
                                    path: "/home/marketing/themanagement",
                                    title: "直播管理",
                                    children: [
                                        {
                                            path: "/home/marketing/themanagement/live_streaming",
                                            title: "直播列表"
                                        },
                                        {
                                            path: "/home/marketing/themanagement/create_live",
                                            title: "创建直播"
                                        },
                                        {
                                            to: "/home/marketing/themanagement/live_streaming",
                                            from: "/home/marketing/themanagement"
                                        }
                                    ]
                                },
                                // {
                                //     path: "/home/marketing/group_booking",

                                //     title: "拼团管理",
                                //     children: [
                                //         {
                                //             path: "/home/marketing/group_booking/booking_shop",
                                //             title: "拼团商品"
                                //         },
                                //         {
                                //             path: "/home/marketing/group_booking/booking_list",
                                //             title: "拼团列表"
                                //         },
                                //         {
                                //             to: "/home/marketing/group_booking/booking_shop",
                                //             from: "/home/marketing/group_booking"
                                //         }
                                //     ]
                                // },
                                {
                                    to: "/home/marketing/seckill",
                                    from: "/home/marketing"
                                }
                            ]
                        },
                        // {
                        //     path: "/home/order",
                        //     title: "订单",
                        //     children: [
                        //         {
                        //             path: "/home/order/orderadmin",
                        //             title: "订单管理"
                        //         },
                        //         {
                        //             path: "/home/order/order_summarace",
                        //             title: "订单概述"
                        //         },
                        //         {
                        //             path: "/home/order/evaluate",
                        //             title: "评价管理"
                        //         },
                        //         {
                        //             path: "/home/order/distribution",
                        //             title: "订单配送"
                        //         },
                        //         {
                        //             to: "/home/order/orderadmin",
                        //             from: "/home/order"
                        //         }
                        //     ]
                        // },
                    ]
                }]
            ]
        }

    };
}


module.exports = HomeController;

